---
title: Spec - howl.ui.Window
tags: spec
---
<div class="spec-group spec-group-1">

<h1 id="howl.ui.window">howl.ui.Window</h1>

<pre class="highlight moonscript"><code><span class="kd">local</span><span class="w"> </span><span class="n">win</span><span class="w">

</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">
  </span><span class="n">win</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Window</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">realize</span><span class="o">!</span></code></pre>

<div class="spec-group spec-group-2">

<h2 id="add_view(view-[,-placement,-anchor])">add_view(view [, placement, anchor])</h2>

<h4 id="adds-the-specified-view">adds the specified view</h4>

<pre class="highlight moonscript"><code><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="o">#</span><span class="n">win</span><span class="p">.</span><span class="n">views</span></code></pre>


<h4 id="returns-a-table-containing-x,-y,-width,-height-and-the-view">returns a table containing x, y, width, height and the view</h4>

<pre class="highlight moonscript"><code><span class="n">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">label</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">label</span></code></pre>


<h4 id="adds-the-new-view-to-the-right-of-the-currently-focused-one-by-default">adds the new view to the right of the currently focused one by default</h4>

<pre class="highlight moonscript"><code><span class="n">entry</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">entry</span><span class="w">
</span><span class="n">entry</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">label</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">label</span></code></pre>

<div class="spec-group spec-group-3">

<h3 id="(when-placement-is-specified)">(when placement is specified)</h3>

<pre class="highlight moonscript"><code><span class="kd">local</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="n">entry</span><span class="w">

</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">
  </span><span class="n">entry</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">entry</span><span class="w">
  </span><span class="n">entry</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
  </span><span class="n">view</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span></code></pre>


<h4 id="&quot;right_of&quot;-places-the-view-on-the-right-side-of-the-focused-child">&quot;right_of&quot; places the view on the right side of the focused child</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'right_of'</span></code></pre>


<h4 id="&quot;left_of&quot;-places-the-view-on-the-left-side-of-the-focused-child">&quot;left_of&quot; places the view on the left side of the focused child</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'left_of'</span></code></pre>


<h4 id="&quot;above&quot;-places-the-view-above-the-focused-child">&quot;above&quot; places the view above the focused child</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'above'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">entry</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">entry</span></code></pre>


<h4 id="&quot;below&quot;-places-the-view-below-the-focused-child">&quot;below&quot; places the view below the focused child</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span></code></pre>


<h4 id="allows-specifying-the-relative-view-to-use-with-placement">allows specifying the relative view to use with placement</h4>

<pre class="highlight moonscript"><code><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span><span class="w">
</span><span class="n">next_view</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">next_view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">next_view</span><span class="p">,</span><span class="w"> </span><span class="s1">'left_of'</span><span class="p">,</span><span class="w"> </span><span class="n">view</span></code></pre>


<h4 id="creates-new-columns-as-needed">creates new columns as needed</h4>

<pre class="highlight moonscript"><code><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">view</span><span class="p">,</span><span class="w"> </span><span class="s1">'right_of'</span><span class="w">
</span><span class="n">next_view</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">next_view</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">next_view</span><span class="p">,</span><span class="w"> </span><span class="s1">'left_of'</span><span class="p">,</span><span class="w"> </span><span class="n">view</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">[</span><span class="n">v</span><span class="p">.</span><span class="n">x</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="o">*</span><span class="n">win</span><span class="p">.</span><span class="n">views</span><span class="p">]</span></code></pre>

</div>
</div>
<div class="spec-group spec-group-2">

<h2 id="remove_view(view)">remove_view(view)</h2>

<h4 id="removes-the-specified-view">removes the specified view</h4>

<pre class="highlight moonscript"><code><span class="n">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">label</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">label</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="o">#</span><span class="n">win</span><span class="p">.</span><span class="n">views</span></code></pre>


<h4 id="removes-the-currently-focused-child-if-view-is-nil">removes the currently focused child if view is nil</h4>

<pre class="highlight moonscript"><code><span class="n">entry</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">entry</span><span class="w">
</span><span class="n">entry</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="o">#</span><span class="n">win</span><span class="p">.</span><span class="n">views</span></code></pre>


<h4 id="raises-an-error-if-view-is-nil-and-no-child-has-focus">raises an error if view is nil and no child has focus</h4>

<pre class="highlight moonscript"><code><span class="n">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">label</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">raises</span><span class="w"> </span><span class="s1">'remove'</span><span class="p">,</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="o">!</span></code></pre>


<h4 id="set-focus-on-its-later-sibling-is-possible">set focus on its later sibling is possible</h4>

<pre class="highlight moonscript"><code><span class="n">left</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">middle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">right</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">left</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">middle</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">right</span><span class="w">
</span><span class="n">middle</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">middle</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">right</span><span class="p">.</span><span class="n">is_focus</span></code></pre>


<h4 id="set-focus-on-its-earlier-sibling-if-no-later-sibling-exists">set focus on its earlier sibling if no later sibling exists</h4>

<pre class="highlight moonscript"><code><span class="n">left</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">middle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">right</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">left</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">middle</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">right</span><span class="w">
</span><span class="n">right</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">right</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">middle</span><span class="p">.</span><span class="n">is_focus</span></code></pre>

</div>
<div class="spec-group spec-group-2">

<h2 id=".views">.views</h2>

<h4 id="is-a-table-of-view-tables,-containing-x,-y-and-the-view-itself">is a table of view tables, containing x, y and the view itself</h4>

<pre class="highlight moonscript"><code><span class="n">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">label</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">label</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="p">.</span><span class="n">views</span></code></pre>


<h4 id="ordered-ascendingly">ordered ascendingly</h4>

<pre class="highlight moonscript"><code><span class="n">entry</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">entry</span><span class="w">
</span><span class="n">entry</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">

</span><span class="n">l1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">l2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Label</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">l1</span><span class="p">,</span><span class="w"> </span><span class="s1">'left_of'</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">l2</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">l1</span><span class="p">,</span><span class="w"> </span><span class="n">entry</span><span class="p">,</span><span class="w"> </span><span class="n">l2</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="p">[</span><span class="n">v</span><span class="p">.</span><span class="n">view</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="o">*</span><span class="n">win</span><span class="p">.</span><span class="n">views</span><span class="p">]</span></code></pre>

</div>
<div class="spec-group spec-group-2">

<h2 id=".current_view">.current_view</h2>

<h4 id="is-nil-if-no-child-is-currently-focused">is nil if no child is currently focused</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="p">,</span><span class="w"> </span><span class="n">win</span><span class="p">.</span><span class="n">current_view</span></code></pre>


<h4 id="is-a-table-containing-x,-y-and-the-view-for-the-currently-focused-view">is a table containing x, y and the view for the currently focused view</h4>

<pre class="highlight moonscript"><code><span class="n">e1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">e2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">e1</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">e2</span><span class="w">

</span><span class="n">e1</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">e1</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="p">.</span><span class="n">current_view</span><span class="w">

</span><span class="n">e2</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">e2</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="p">.</span><span class="n">current_view</span></code></pre>

</div>
<div class="spec-group spec-group-2">

<h2 id="siblings(view,-wraparound)">siblings(view, wraparound)</h2>

<h4 id="returns-an-empty-table-if-there-are-no-siblings">returns an empty table if there are no siblings</h4>

<pre class="highlight moonscript"><code><span class="n">v1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">v1</span><span class="w">
  </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">v1</span></code></pre>


<h4 id="defaults-to-the-currently-focused-child-if-view-is-not-provided">defaults to the currently focused child if view is not provided</h4>

<pre class="highlight moonscript"><code><span class="n">v1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">v1</span><span class="w">
  </span><span class="n">v1</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
  </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="o">!</span></code></pre>


<h4 id="returns-an-empty-table-if-view-is-not-provided-and-no-child-is-focused">returns an empty table if view is not provided and no child is focused</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="o">!</span></code></pre>

<div class="spec-group spec-group-3">

<h3 id="(when-wraparound-is-false)">(when wraparound is false)</h3>

<h4 id="returns-a-table-of-siblings-for-the-specified-view-when-present">returns a table of siblings for the specified view when present</h4>

<pre class="highlight moonscript"><code><span class="n">left</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
 </span><span class="n">right</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
 </span><span class="n">bottom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
 </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">left</span><span class="w">
 </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="s1">'right_of'</span><span class="p">,</span><span class="w"> </span><span class="n">left</span><span class="w">
 </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span><span class="p">,</span><span class="w"> </span><span class="n">left</span><span class="w">

 </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">right:</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="ss">down:</span><span class="w"> </span><span class="n">bottom</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span><span class="w">
 </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">left:</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="ss">down:</span><span class="w"> </span><span class="n">bottom</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span><span class="w">
 </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">up:</span><span class="w"> </span><span class="n">left</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span></code></pre>

</div>
<div class="spec-group spec-group-3">

<h3 id="(when-wraparound-is-true)">(when wraparound is true)</h3>

<h4 id="returns-a-table-of-siblings-for-the-specified-view-in-a-wraparound-fashion">returns a table of siblings for the specified view in a wraparound fashion</h4>

<pre class="highlight moonscript"><code><span class="n">left</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">right</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">bottom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">left</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="s1">'right_of'</span><span class="p">,</span><span class="w"> </span><span class="n">left</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span><span class="p">,</span><span class="w"> </span><span class="n">left</span><span class="w">

  </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">left:</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="ss">right:</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="ss">up:</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="ss">down:</span><span class="w"> </span><span class="n">bottom</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="w">
  </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">left:</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="ss">right:</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="ss">up:</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="ss">down:</span><span class="w"> </span><span class="n">bottom</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span><span class="w">
  </span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">left:</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="ss">right:</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="ss">up:</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="ss">down:</span><span class="w"> </span><span class="n">left</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">siblings</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span></code></pre>

</div>
</div>
<div class="spec-group spec-group-2">

<h2 id="column-reflowing">column reflowing</h2>

<pre class="highlight moonscript"><code><span class="kd">local</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="n">bottom</span><span class="w">

</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">
  </span><span class="n">left</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">right</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">bottom</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">left</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">right</span><span class="w">
  </span><span class="n">right</span><span class="o">\</span><span class="n">grab_focus</span><span class="o">!</span><span class="w">
  </span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="s1">'below'</span></code></pre>


<h4 id="single-columns-as-expanded-as-necessary">single columns as expanded as necessary</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">bottom</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">bottom</span></code></pre>


<h4 id="columns-to-the-right-are-adjusted-after-a-remove-of-a-left-column">columns to the right are adjusted after a remove of a left column</h4>

<pre class="highlight moonscript"><code><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">left</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">right</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">right</span></code></pre>


<h4 id="columns-to-the-left-are-adjusted-after-a-remove-of-a-right-column">columns to the left are adjusted after a remove of a right column</h4>

<pre class="highlight moonscript"><code><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">right</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">left</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">left</span></code></pre>


<h4 id="rows-are-adjusted-after-removal-of-a-middle-column">rows are adjusted after removal of a middle column</h4>

<pre class="highlight moonscript"><code><span class="n">middle</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">middle</span><span class="p">,</span><span class="w"> </span><span class="s1">'right_of'</span><span class="p">,</span><span class="w"> </span><span class="n">left</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">remove_view</span><span class="w"> </span><span class="n">middle</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">left</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">left</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="ss">x:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">y:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">width:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">height:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">view:</span><span class="w"> </span><span class="n">right</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">win</span><span class="o">\</span><span class="n">get_view</span><span class="w"> </span><span class="n">right</span></code></pre>

</div>
<div class="spec-group spec-group-2">

<h3 id="(resource-management)">(resource management)</h3>

<h4 id="added-views-are-not-anchored">added views are not anchored</h4>

<pre class="highlight moonscript"><code><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">Entry</span><span class="o">!</span><span class="w">
</span><span class="n">views</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">setmetatable</span><span class="w"> </span><span class="p">{</span><span class="n">v</span><span class="p">},</span><span class="w"> </span><span class="ss">__mode:</span><span class="w"> </span><span class="s1">'v'</span><span class="w">
</span><span class="n">win</span><span class="o">\</span><span class="n">add_view</span><span class="w"> </span><span class="n">v</span><span class="w">
</span><span class="n">v</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">nil</span><span class="w">
</span><span class="nb">collectgarbage</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="n">views</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code></pre>

</div>
</div>
